package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.feign.order.OrderFeignClient;
import com.atguigu.gmall.order.entity.OrderInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class PayController {

    @Autowired
    OrderFeignClient orderFeignClient;

    //  http://payment.gmall.com/pay.html?orderId=813811562849501184
    @GetMapping("/pay.html")
    public String payPage(@RequestParam("orderId") Long orderId, Model model){
        //远程调用 查询订单数据
        OrderInfo orderInfo = orderFeignClient.getOrderInfoById(orderId).getData();
        model.addAttribute("orderInfo", orderInfo);
        return "payment/pay";
    }

    //支付成功后跳转的页面
    @GetMapping("/pay/success.html")
    public String paySuccess(){
        //订单状态不能在这个页面被访问的时候修改订单状态
        return "payment/success";
    }
}
